home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
038a
/
aplibs91.zip
/
2ERRORS.BAS
next >
Wrap
BASIC Source File
|
1991-04-10
|
4KB
|
115 lines
' DUMMY FILE WITH ERRORS -- TO TEST THE
' POWER-BASIC - QEDIT INTERFACE
' (Don't fix the errors now, dummy! Just exit QEdit and let it try to compile.
' After the first error is located by your computer, then fix it and exit
' again. It should compile successfully and bomb during execution (can you
' guess where ... ?? )
$COMPILE EXE
$ERROR ALL ON
$OPTION CNTLBREAK ON
DEFINT A-Z
%False = 0
%True = NOT %False
SourceFile$ = "2ERRORS.BAS"
SourceDir$ = "." ' set up error handling
RDisk$ = "." ' temp files will go in current dir (".") --
' change if you wish ...
GoToSourceFile = %True ' if you use QEdit, set this var as
ON ERROR GOTO Oops2 ' true and you'll get automatic
' search for runtime errors when
' working from the command line --
' just like you do in the PB environment
' code
' more code
' more code
' more code
' more code
' more code
' more code
' more code
CLS
'THIS IS AN ERROR
A$ = 0
LOCATE 3, 1, 0
PRINT " ┌───────────────────────────────────────────┐"
PRINT " │ │"
PRINT " │ 2ERRORS.EXE IS ABOUT TO BOMB ... │"
PRINT " │ │"
PRINT " └───────────────────────────────────────────┘"
PRINT
DELAY 1
PLAY "O3 T180 MS E8 E4 E4 < B8 > C#4 < A4 P4 > A8"
' more code
' more code
' more code
' more code
' more code
' more code
' more code
LOCATE 0,0
PRINT "HELLO"
END
SUB BufferStuffer (M$)
IF LEN (M$) > 15 THEN PLAY "O2 E32 P8 O1 C4": M$ = "COMMAND"+CHR$(255)+"2 LONG"
L = LEN (M$)
DEF SEG = 0
POKE 1050, 30
POKE 1052, 30 + 2 * L
FOR I = 1 TO L
POKE 1052 + 2*I, ASCII (MID$ (M$,I,1))
NEXT
END SUB
Oops2:
' ERROR HANDLING SUBROUTINE
' =======================
DO: LOOP UNTIL INKEY$ = "" ' first purge the keyboard buffer
' for all other errors we notify
PLAY "ML O0 C16 D64" ' user and quit ... UNLESS you set
PRINT " OOPS! UNABLE TO CONTINUE. ERROR";ERR;" AT ADDRESS ";ERADR;" "
IF GoToSourceFile THEN ' this triggers the ERFIND sequence
CLS
IF DIR$ (RDisk$ + "GETERR.&BA") <> "" THEN KILL RDisk$ + "GETERR.&BA"
IF DIR$ (RDisk$ + "GETERR.BAT") <> "" THEN
NAME RDisk$ + "GETERR.BAT" AS RDisk$ + "GETERR.&BA"
END IF
OutBat = FREEFILE
OPEN RDisk$ + "GETERR.BAT" FOR OUTPUT AS #OutBat ' create output bat file
A$ = "@echo off"
PRINT #OutBat, A$
A$ = "cd " + SourceDir$
PRINT #OutBat, A$
A$ = "error " + STR$ (ERR) ' this calls ERROR.EXE to tell
PRINT #OutBat, A$ ' you what went wrong ...
A$ = "pbc /re" + LTRIM$ (STR$ (ERADR)) + " " + SourceFile$
PRINT #OutBat, A$
A$ = "ERFIND " + SourceFile$
PRINT #OutBat, A$
CLOSE #OutBat
CALL BufferStuffer (RDisk$ + "GETERR" + CHR$(13)) ' and run it
END IF
END 1 ' ┌──────────────────────────────────────────────────────────┐
' │ I downloaded ERROR.EXE, by Rodney Jones, from the │
RESUME ' │ CompuServe PCVEN-B forum. A good work, very helpful ! │
' └──────────────────────────────────────────────────────────┘